package controlLayer;

import modelLayer.LoanContainer;
import modelLayer.Loan;
import modelLayer.Copy;
import modelLayer.Person;
/**
 * Write a description of class LoanCtr here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class LoanCtr
{
    // instance variables - replace the example below with your own
    private Loan loan;
    private LoanContainer loanCon;

    /**
     * Constructor for objects of class LoanCtr
     */
    public LoanCtr()
    {
        loanCon= LoanContainer.getInstance();
    }

    public void createLoan(Copy copy,Person person, String id, String borrowDate, String period, String state)
    {
        loan = new Loan(copy,person, id, borrowDate, period, state);
        loanCon.addLoan(loan);
    }
    
    // Find a loan
    public Loan findLoan(String id) 
    {
        return loanCon.getLoan(id);
    }
    
    // Update a loan
    public void updateLoan(Loan loan, String period) 
    {
        loanCon.updateLoan(loan,period);
    }
    
    // Delete a loan
    public void deleteLoan(Loan loan) 
    {
        loanCon.deleteLoan(loan);
    }
    
    // Update state = Register return
    public void registerReturn(Loan loan, String state) 
    {
        loanCon.registerReturn(loan,state);
    }
}
